<?php
/**
 * Short Description  
 *
 * Long Description 
 *
 * @category   
 * @package    
 * @subpackage 
 * @copyright 
 * @author     Sandeep Manne<sandeep.manne@costrategix.com>
 */

class LoginForm extends Core_Form_Abstract
{
	public function setForm($options)
    {
        /**
         * @see Core_Form
         */
        require_once 'Core/Form.php';
        $form = $this->_form = new Core_Form();
   	    $form->setAction('')->setMethod('post');

   	    $username = $form->createElement('text', 'username')
   	                     ->setLabel($this->__('Username:'))
                         ->addValidator('EmailAddress')
           	             ->setRequired(true)
           	             ->addFilter('StringToLower');

   	    $password = $form->createElement('password', 'password')
   	                     ->setLabel($this->__('Password:'))
   	                     ->addValidator('StringLength', false, array(6))
   	                     ->setRequired(true);

		$persistent = $form->createElement('checkbox', 'persistent')
   	                       ->setLabel($this->__('Remember Me:'));

   	    $submit = $form->createImageButton('submit', 'images/global/buttons/signin.png');

        $submit->getDecorator('HtmlTag')
               ->setOption('class', 'form-buttons clear');
               
        $csrf   = $form->createElement('hash', 'csrf_login', array('salt' => 'unique'))
        			   ->setErrorMessages(array("CSRF Token validation failed"));

   	    $form->addElements(array(
   	        $username,
   	        $password,
        ));
        	
        $form->addDisplayGroup(
            array(
       	        $username->getName(),
       	        $password->getName(),
       	        //$persistent->getName()
            ),
            'login',
            array(
                'legend' => $this->__('Your Account')
            )
        );
        $form->addElements(array($submit));
    }

	public static function getForm($options = null)
    {
        if (null === self::$_instance) {
            self::$_instance = new self($options);
        }

        return self::$_instance->_form;
    }
	
}